var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (i, e) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, i) {
              t.__proto__ = i;
            }) ||
          function (t, i) {
            for (var e in i)
              Object.prototype.hasOwnProperty.call(i, e) && (t[e] = i[e]);
          })(i, e);
      };
      return function (i, e) {
        function o() {
          this.constructor = i;
        }
        if ("function" != typeof e && null !== e)
          throw new TypeError(
            "Class extends value " + String(e) + " is not a constructor or null"
          );
        t(i, e),
          (i.prototype =
            null === e
              ? Object.create(e)
              : ((o.prototype = e.prototype), new o()));
      };
    })(),
  HonorFieldHomeView = (function (t) {
    function i() {
      var i = t.call(this) || this;
      return (
        (i.timeDiff = 0),
        (i.listArr = []),
        (i.listCampArr = []),
        (i.allowFight = !1),
        (i.followHonorState = !1),
        (i.left_Msg = ""),
        (i.right_Msg = ""),
        i.btn_bonor_back.on(Laya.Event.CLICK, i, i.onHonorFieldBackAction),
        i.btn_honor_GZSM.on(Laya.Event.CLICK, i, i.OnDidClickGZSMAction),
        i.btn_honor_JLSM.on(Laya.Event.CLICK, i, i.OnDidClickJLSMAction),
        i.btn_honor_order.on(Laya.Event.CLICK, i, i.OnDidClickHonorOrderAction),
        i.btn_honor_juezhan_start.on(
          Laya.Event.CLICK,
          i,
          i.onDidClickJueSaiStartAction
        ),
        i.btn_honor_main_quit.on(
          Laya.Event.CLICK,
          i,
          i.onDidClickHonorMainQuitAction
        ),
        (i.list_honor_last_rank.vScrollBarSkin = ""),
        (i.list_honor_last_rank.selectEnable = !0),
        i.list_honor_last_rank.on(
          Laya.Event.CLICK,
          i,
          i.onDidClickHonorLastRankAction
        ),
        (i.list_honor_seq.vScrollBarSkin = ""),
        (i.list_honor_seq.selectEnable = !0),
        i.list_honor_seq.on(Laya.Event.CLICK, i, i.onDidClickHonorSeqAction),
        (i.list_honor_main.vScrollBarSkin = ""),
        (i.list_honor_main.selectEnable = !0),
        (i.list_honor_main.renderHandler = new Handler(
          i,
          i.onUpdateHonorMainRender
        )),
        i.list_honor_main.on(Laya.Event.CLICK, i, i.onDidClickHonorMainAction),
        i.tab_honor_item0.on(Laya.Event.CLICK, i, i.onTabHonorItemDidClick),
        i.tab_honor_item1.on(Laya.Event.CLICK, i, i.onTabHonorItemDidClick),
        i.tab_honor_item2.on(Laya.Event.CLICK, i, i.onTabHonorItemDidClick),
        WebSocketService.addListener({
          caller: i,
          code: 1524,
          method: i.onHonorHomeData,
        }),
        WebSocketService.addListener({
          caller: i,
          code: 1551,
          method: i.onLoadLastRankData,
        }),
        WebSocketService.addListener({
          caller: i,
          code: 1549,
          method: i.onLoadDuiZhenGrourpData,
        }),
        WebSocketService.addListener({
          caller: i,
          code: 1556,
          method: i.onLoadHonorOrderDataFn,
        }),
        WebSocketService.addListener({
          caller: i,
          code: 1552,
          method: i.onLoadHonorQuitHonorData,
        }),
        WebSocketService.addListener({
          caller: i,
          code: 1537,
          method: i.onLoadBangPaiDaZhanMessageData,
        }),
        WebSocketService.addListener({
          caller: i,
          code: 1538,
          method: i.onLoadHonorMainHomeData,
        }),
        WebSocketService.addListener({
          caller: i,
          code: 1528,
          method: i.onLoadHonorFaQiData,
        }),
        i
      );
    }
    return (
      __extends(i, t),
      (i.showHonorFieldView = function () {
        return (
          null == this.honorFieldV && (this.honorFieldV = new i()),
          WebSocketService.send({ c: 1524 }),
          this.honorFieldV.init(),
          this.honorFieldV
        );
      }),
      (i.prototype.init = function () {
        (this.image_honor_item_waiting.visible = !1),
          (this.image_honor_item_juesai.visible = !1),
          (this.image_honor_item_main.visible = !1),
          (this.label_list_rank_empty.text = ""),
          (this.label_list_rank_empty.visible = !1);
      }),
      (i.prototype.onHonorHomeData = function (t) {
        this.init(),
          0 == t.code &&
            ((this.honorState = t.data.s),
            WebSocketService.send({ c: 1549 }),
            "0" == this.honorState || "1" == this.honorState
              ? ((this.label_honor_item1_title.text = "上一届帮派决战排名"),
                WebSocketService.send({ c: 1551 }),
                (this.list_honor_last_rank.visible = !1),
                (this.list_honor_seq.visible = !1),
                (this.left_Msg = "距离比赛开始还有"))
              : "2" == this.honorState
              ? ((this.label_honor_item1_title.text = "第一轮淘汰战斗"),
                (this.left_Msg = "距离第一轮淘汰赛开始还有"))
              : "3" == this.honorState
              ? (this.left_Msg = "距离第二轮淘汰赛开始还有")
              : "5" == this.honorState ||
                "7" == this.honorState ||
                ("25" == this.honorState
                  ? (this.left_Msg = "第一轮淘汰赛入场倒计时")
                  : "26" == this.honorState
                  ? ((this.left_Msg = "距离第一轮淘汰赛战斗结束还有"),
                    (this.tab_honor_item0.selected = !1),
                    (this.tab_honor_item1.selected = !0),
                    (this.tab_honor_item2.selected = !1))
                  : "35" == this.honorState
                  ? (this.left_Msg = "第二轮淘汰赛入场倒计时")
                  : "36" == this.honorState
                  ? ((this.left_Msg = "距离第二轮淘汰赛战斗结束还有"),
                    WebSocketService.send({ c: 1537 }))
                  : "56" == this.honorState &&
                    ((this.left_Msg = "距离决赛结束还有"),
                    WebSocketService.send({ c: 1537 }))),
            this.updateHonorFieldView(this.honorState),
            (this.timeDiff = Math.floor(t.data.t)),
            (this.label_honor_timeDown.text =
              this.left_Msg +
              Utils.timeCountDown(this.timeDiff) +
              this.right_Msg),
            Laya.timer.loop(1e3, this, this.timerCountDownMatchFn));
      }),
      (i.prototype.updateHonorFieldView = function (t) {
        (this.btn_honor_GZSM.visible = !0),
          (this.btn_honor_JLSM.visible = !0),
          (this.btn_honor_order.visible = !1),
          "0" == t || "1" == t
            ? ((this.image_honor_item_waiting.visible = !0),
              (this.image_honor_item_juesai.visible = !1),
              (this.image_honor_item_main.visible = !1))
            : "2" == t
            ? ((this.image_honor_item_juesai.visible = !1),
              (this.image_honor_item_waiting.visible = !0),
              (this.image_honor_item_main.visible = !1),
              (this.btn_honor_GZSM.visible = !1),
              (this.btn_honor_JLSM.visible = !1))
            : "25" == t
            ? ((this.image_honor_item_waiting.visible = !0),
              (this.image_honor_item_juesai.visible = !1),
              (this.image_honor_item_main.visible = !1),
              (this.btn_honor_order.visible = !0),
              (this.list_honor_main.visible = !1),
              (this.list_honor_last_rank.visible = !1))
            : "26" == t
            ? ((this.btn_honor_order.visible = !0),
              (this.image_honor_item_waiting.visible = !0),
              (this.image_honor_item_juesai.visible = !1),
              (this.image_honor_item_main.visible = !1),
              (this.list_honor_seq.visible = !1))
            : "35" == t
            ? ((this.image_honor_item_waiting.visible = !0),
              (this.image_honor_item_juesai.visible = !1),
              (this.image_honor_item_main.visible = !1))
            : "36" == t
            ? ((this.image_honor_item_waiting.visible = !0),
              (this.image_honor_item_juesai.visible = !1),
              (this.image_honor_item_main.visible = !1),
              (this.btn_honor_order.visible = !0),
              (this.list_honor_last_rank.visible = !1),
              (this.list_honor_seq.visible = !1))
            : "55" == t
            ? ((this.image_honor_item_waiting.visible = !1),
              (this.image_honor_item_juesai.visible = !0),
              (this.image_honor_item_main.visible = !1))
            : "56" == t &&
              ((this.image_honor_item_waiting.visible = !1),
              (this.image_honor_item_juesai.visible = !0),
              (this.image_honor_item_main.visible = !1),
              (this.list_honor_main.visible = !1));
      }),
      (i.prototype.timerCountDownMatchFn = function () {
        this.timeDiff--,
          this.timeDiff >= 0
            ? ((this.label_honor_timeDown.text =
                this.left_Msg +
                Utils.timeCountDown(this.timeDiff) +
                this.right_Msg),
              this.timeDiff % 10 == 0 &&
                (1 == this.followHonorState
                  ? WebSocketService.send({ c: 1537 })
                  : WebSocketService.send({ c: 1524 })))
            : (Laya.timer.clear(this, this.timerCountDownMatchFn),
              (this.label_honor_timeDown.text = "请稍等..."),
              WebSocketService.send({ c: 1524 }));
      }),
      (i.prototype.onLoadDuiZhenGrourpData = function (t) {
        if (
          ((this.list_honor_last_rank.visible = !1),
          (this.list_honor_seq.visible = !1),
          0 == t.code && t.data)
        ) {
          this.listArr = t.data;
          var i = void 0;
          if (
            ((this.dataSource = []),
            "56" == this.honorState || "55" == this.honorState)
          )
            for (var e = 0; e < this.listArr.length; e++) {
              n = this.listArr[e];
              0 == e
                ? ((this.label_first_item1.text = n.n1),
                  (this.label_first_item2.text = n.n2))
                : ((this.label_second_item1.text = n.n1),
                  (this.label_second_item2.text = n.n2));
            }
          else {
            this.listArr.length > 0
              ? ((this.label_list_rank_empty.visible = !1),
                (this.label_list_rank_empty.text = ""),
                (this.list_honor_last_rank.visible = !0))
              : ((this.label_list_rank_empty.visible = !0),
                (this.label_list_rank_empty.text = "当前暂无比赛记录"));
            for (var o = 0; o < this.listArr.length; o++) {
              var n;
              (n = this.listArr[o]).c1 &&
                n.s1 &&
                "(" + n.s1 + "人" + n.c1 + "胜)",
                n.c2 && n.s2 && "(" + n.s2 + "人" + n.c2 + "胜)",
                (i = {
                  label_item_rank1: { text: n.n1 },
                  label_item_rank2: { text: this.listArr[o].n2 },
                }),
                this.dataSource.push(i);
            }
            this.list_honor_last_rank.dataSource = this.dataSource;
          }
        }
      }),
      (i.prototype.onLoadLastRankData = function (t) {
        if (0 == t.code) {
          this.listArr = [];
          var i = void 0;
          if (this.currentPage >= 1) {
            if (0 == t.list.length) return void this.currentPage--;
            for (var e = 0; e < t.data.length; e++) {
              var o = t.list[e];
              this.listArr.push(o), (this.dataSource = []);
            }
          } else (this.listArr = t.data), (this.dataSource = []);
          if (
            ((this.isloading = !1),
            "0" == this.honorState || "1" == this.honorState)
          ) {
            this.listArr.length > 0
              ? ((this.label_list_rank_empty.visible = !1),
                (this.label_list_rank_empty.text = ""),
                (this.list_honor_seq.visible = !0))
              : ((this.list_honor_seq.visible = !0),
                (this.label_list_rank_empty.text = "当前暂无比赛记录"));
            for (var n = 0; n < this.listArr.length; n++) {
              (i = {
                label_honor_seq: { text: (a = this.listArr[n]).i + ". " + a.n },
              }),
                this.dataSource.push(i);
            }
            this.list_honor_seq.dataSource = this.dataSource;
          } else {
            this.listArr.length > 0
              ? ((this.label_list_rank_empty.visible = !1),
                (this.label_list_rank_empty.text = ""),
                (this.list_honor_last_rank.visible = !0))
              : ((this.label_list_rank_empty.visible = !0),
                (this.label_list_rank_empty.text = "当前暂无比赛记录"));
            for (var s = 0; s < this.listArr.length; s++) {
              var a = this.listArr[s];
              (i = {
                label_item_rank1: { text: a.n },
                label_item_rank2: { text: "" },
              }),
                this.dataSource.push(i);
            }
            this.list_honor_last_rank.dataSource = this.dataSource;
          }
        }
      }),
      (i.prototype.onLoadHonorOrderDataFn = function (t) {
        0 == t.code
          ? ((this.image_honor_item_waiting.visible = !1),
            (this.image_honor_item_juesai.visible = !1),
            (this.image_honor_item_main.visible = !0),
            (this.btn_honor_GZSM.visible = !1),
            (this.btn_honor_JLSM.visible = !1),
            (this.followHonorState = !0),
            (this.list_honor_main.visible = !1))
          : ToastView.toastView(t.msg);
      }),
      (i.prototype.OnDidClickGZSMAction = function () {
        var t = RulesView.showCaslRuleView("honorGZSM");
        (t.y = 0), Laya.stage.addChild(t);
      }),
      (i.prototype.OnDidClickJLSMAction = function () {
        var t = RulesView.showCaslRuleView("honorJLSM");
        (t.y = 0), Laya.stage.addChild(t);
      }),
      (i.prototype.OnDidClickHonorOrderAction = function () {
        WebSocketService.send({ c: 1556 }),
          WebSocketService.send({ c: 1537 }),
          WebSocketService.send({ c: 1538, d: { t: 1, pageNum: 0 } });
      }),
      (i.prototype.onDidClickHonorMainQuitAction = function () {
        NormalDialog.showNormalDialog(
          "您确定要退出战场么？退出视为弃权，将无法再加入战场。",
          this,
          this.onQuitZhanChangAction
        );
      }),
      (i.prototype.onQuitZhanChangAction = function () {
        WebSocketService.send({ c: 1552 }), (this.followHonorState = !1);
      }),
      (i.prototype.onLoadHonorQuitHonorData = function (t) {
        WebSocketService.send({ c: 1524 });
      }),
      (i.prototype.onDidClickJueSaiStartAction = function () {
        (this.followHonorState = !0), WebSocketService.send({ c: 1556 });
      }),
      (i.prototype.onDidClickHonorSeqAction = function (t) {
        if ("" != t.target.name) {
          var i = this.listArr[this.list_honor_seq.selectedIndex];
          if (i) {
            var e = { type: "juesai", title: i.n, bangpaiId: i.id },
              o = GangWarsManagerView.showGangWarsMgrView(e);
            Laya.stage.addChild(o);
          }
        }
      }),
      (i.prototype.onLoadBangPaiDaZhanMessageData = function (t) {
        if (0 == t.code) {
          var i = t.data;
          this.label_honor_main_title.text =
            i.n1 +
            "（" +
            i.s1 +
            "人" +
            i.c1 +
            "胜）  VS  " +
            i.n2 +
            "（" +
            i.s2 +
            "人" +
            i.c2 +
            "胜）";
        }
      }),
      (i.prototype.onTabHonorItemDidClick = function (t) {
        var i = "";
        (this.tab_honor_item0.selected = !1),
          (this.tab_honor_item1.selected = !1),
          (this.tab_honor_item2.selected = !1),
          "item0" == t.target.name
            ? ((i = "0"), (this.tab_honor_item0.selected = !0))
            : "item1" == t.target.name
            ? ((i = "1"), (this.tab_honor_item1.selected = !0))
            : "item2" == t.target.name &&
              ((i = "2"), (this.tab_honor_item2.selected = !0)),
          (this.tab_honor_item0.disabled = this.allowFight),
          WebSocketService.send({ c: 1538, d: { t: i, pageNum: 0 } });
      }),
      (i.prototype.onLoadHonorMainHomeData = function (t) {
        if (0 == t.code) {
          this.listCampArr = [];
          var i = void 0;
          if (void 0 == t.list) return void (this.list_honor_main.visible = !1);
          if (this.currentPage >= 1) {
            if (0 == t.list.length) return void this.currentPage--;
            for (var e = 0; e < t.data.length; e++) {
              var o = t.list[e];
              this.listCampArr.push(o), (this.dataSource = []);
            }
          } else (this.listCampArr = t.list), (this.dataSource = []);
          if (
            ((this.isloading = !1),
            (this.label_honor_subMain_title.text =
              "敌方（" + t.more[0] + "人）VS 我方（" + t.more[1] + "人)"),
            this.listCampArr.length > 0)
          ) {
            var n = 0;
            this.listCampArr.forEach(function (t) {
              0 == t.s && n++;
            }),
              1 == this.tab_honor_item1.selected
                ? n > 0
                  ? this.dealTabItemOneDisabled(!1)
                  : this.dealTabItemOneDisabled(!0)
                : this.dealTabItemOneDisabled(this.allowFight),
              (this.list_honor_main.visible = !0);
          } else
            (this.list_honor_main.visible = !1),
              this.dealTabItemOneDisabled(!0);
          for (var s = 0; s < this.listCampArr.length; s++) {
            (i = { label_honor_text: { text: this.listCampArr[s].n } }),
              this.dataSource.push(i);
          }
          this.list_honor_main.dataSource = this.dataSource;
        }
      }),
      (i.prototype.onUpdateHonorMainRender = function (t, i) {
        if (!(i > this.listCampArr.length)) {
          var e = t.getChildByName("btn_honor_fight"),
            o = this.listCampArr[i];
          void 0 != o
            ? "1" == o.s ||
              1 == this.tab_honor_item2.selected ||
              "25" == this.honorState ||
              "35" == this.honorState ||
              "55" == this.honorState
              ? (e.visible = !1)
              : "0" == o.s && (e.visible = !0)
            : (e.visible = !1);
        }
      }),
      (i.prototype.onDidClickHonorMainAction = function (t) {
        if ("" != t.target.name && "btn_honor_fight" == t.target.name) {
          var i = this.listCampArr[this.list_honor_main.selectedIndex];
          WebSocketService.send({ c: 1528, d: { id: i.id } });
        }
      }),
      (i.prototype.onDidClickHonorLastRankAction = function (t) {
        if ("" != t.target.name) {
          var i,
            e = this.listArr[this.list_honor_last_rank.selectedIndex],
            o = "";
          if (
            (t.stageX < 180
              ? ((i = e.id1), (o = e.n1))
              : ((i = e.id2), (o = e.n2)),
            e)
          ) {
            var n = { type: "juesai", title: o, bangpaiId: i },
              s = GangWarsManagerView.showGangWarsMgrView(n);
            Laya.stage.addChild(s);
          }
        }
      }),
      (i.prototype.dealTabItemOneDisabled = function (t) {
        1 == this.tab_honor_item1.selected && (this.allowFight = t),
          (this.tab_honor_item0.disabled = t);
      }),
      (i.prototype.onLoadHonorFaQiData = function (t) {
        0 != t.code && ToastView.toastView(t.msg),
          WebSocketService.send({ c: 1537 }),
          WebSocketService.send({ c: 1538, d: { t: 1, pageNum: 0 } });
      }),
      (i.prototype.onHonorFieldBackAction = function () {
        Laya.timer.clear(this, this.timerCountDownMatchFn),
          Laya.timer.clearAll(this),
          this.removeSelf();
      }),
      i
    );
  })(ui.ChallengeBattle.HonorFieldHomeViewUI);
